﻿using DimensionsHelper.LanguageService.Syntax;

namespace DimensionsHelper.LanguageService.Symbols;

/// <summary>
///     本地函数符号
/// </summary>
public class FunctionSymbol : BindableSymbolWithParameters
{
    internal FunctionSymbol(FunctionDeclaration declarationWithParameters) :
        base(SymbolKinds.Function, declarationWithParameters, null, null)
    {
        // 本地方法默认会返回空值
        if (declarationWithParameters.DeclareKeywordToken.IsNode(SyntaxKinds.FunctionKeywordToken))
        {
            UpdateCachedBinding(ValueTypeSymbol.Null);
        }
    }


    internal FunctionSymbol(FunctionSignature signature, ModuleSymbol? containingModule) :
        base(SymbolKinds.Function, signature, null, containingModule)
    {
    }


    protected FunctionSymbol(MethodSignature signature, NamedTypeSymbol containingSymbol,
        ModuleSymbol? containingModule) :
        base(SymbolKinds.Method, signature, containingSymbol, containingModule)
    {
    }


    public override ModuleSymbol? ContainingModule =>
        ContainingSymbol?.ContainingModule as ModuleSymbol;


    public override bool CanMakeArray => false;


    public override bool IsFunction => true;
    
}